package cn.com.czpb.client.module.personal.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import cn.com.czpb.client.R;
import cn.com.czpb.client.app.ListBaseAdapter;
import cn.com.czpb.client.model.usercenter.ComBean;

/**
 * Created by Administrator on 2017/7/14.
 */

public class CommAdapter extends ListBaseAdapter<ComBean> {
    public CommAdapter(Activity context) {
        super(context);
    }

    @Override
    public View getMyView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            holder=new ViewHolder();
            convertView=inflater.inflate(R.layout.item_comm,parent,false);
            holder.iv_user= convertView.findViewById(R.id.iv_item_comm);
            holder.tv_username= convertView.findViewById(R.id.user_name_item_comm);
            holder.tv_content= convertView.findViewById(R.id.content_item_comm);
            holder.tv_time= convertView.findViewById(R.id.time_item_comm);
            holder.tv_like= convertView.findViewById(R.id.tv_like);
            holder.tv_comm= convertView.findViewById(R.id.tv_pinglun);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
            ComBean cb=list.get(position);
        Glide.with(context).load(cb.getAvatarPath()).placeholder(R.drawable.pic_touxiang).crossFade().into(holder.iv_user);
        holder.tv_username.setText(cb.getNickname());
        holder.tv_content.setText(cb.getContent());
        holder.tv_time.setText(cb.getDateline());
        holder.tv_like.setText(cb.getCount());
        holder.tv_comm.setText(cb.getPraise());


        return convertView;
    }
    class ViewHolder{
        ImageView iv_user;
        TextView tv_username;
        TextView tv_content;
        TextView tv_time;
        TextView tv_like;
        TextView tv_comm;
    }
}
